<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" isELIgnored="false"%>
<%@ include file="/WEB-INF/common/head.jsp"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html lang="zh-CN">
	<head>
		<meta charset="UTF-8">
		<title>部门管理</title>
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<link rel="stylesheet" href="${resource }/css/bootstrap.css" />
		<link rel="stylesheet" type="text/css" href="${resource }/css/iconfont.css">
		<script src="${resource }/js/jquery-2.1.1.min.js"></script>
		<script src="${resource }/js/bootstrap.min.js?v=3.4.0"></script>
		<!-- 分页插件，依赖于jquery位于jquery之后 -->
		<script src="${resource }/js/page.js"></script>
	</head>
	<body>
		<div class="row wrapper border-bottom white-bg page-heading">
			<div class="col-sm-4">
				<h2>部门管理</h2>
				<ol class="breadcrumb">
					<li>
						主页
					</li>
					<li>
						<strong>部门列表</strong>
					</li>
				</ol>
			</div>
		</div>
		<div class="row wrapper border-bottom white-bg page-heading">
			<div class="col-md-12">
				<div class="panel panel-default">
					<div class="panel-heading">
						部门列表
					</div>
					<div class="panel-body">
						<!--table-responsive响应式表格，会自动添加滚动条-->
						<div class="table-responsive">

							<div class="text-center">
								<a  class="btncs btn btn-primary" href="showadddepart.do" style="float: right;">添加部门</a>
							</div>
							<table class="table">
								<thead>
									<tr>
										<th>编号</th>
										<th>部门名称</th>
										<th>部门状态</th>
										<th>部门简介</th>
										<th>操作</th>
									</tr>
								</thead>
								<tbody>
								<c:forEach  items="${departlist }" var="dlist">
								   <c:if test="${dlist.isStop==1}">
								    <c:set var="isstop" value="使用"></c:set>
								  </c:if>
								  <c:if test="${dlist.isStop==0}">
								    <c:set var="isstop" value="禁用"></c:set>
								  </c:if> 
									<tr class="odd gradeX">
										<td>${dlist.id}</td>
										<td>${dlist.deptName}</td>
										<td>${isstop}</td>
										<td>${dlist.deptProfile }</td>
										<td>
											<a title="修改"  class="t-edit" href="showeditdepart.do?id=${dlist.id }" ><i class="iconfont icon-shuru"></i></a>
											<a title="删除" class="t-del"  a href="javascript:void(0);"   onclick="ifdelete('${dlist.id}')"><i class="iconfont icon-shanchu"></i></a>

										</td>
									</tr>
									</c:forEach>
								</tbody>
							</table>
						</div>
						<!--分页显示-->
						<div class="row">
							<div class="col-md-6">
								<div class="pagination" style="margin: 0px;" role="alert" aria-live="polite" aria-relevant="all">显示 1 到 ${department.getPages()} 页 记录数${department.getTotal()}</div>
							</div>
							<!-- 动态分页 -->
							<div class="row">
							<div id="page" class="col-md-6" style="text-align: right;float:right;" ></div>
							</div>
						</div>
						<!--分页显示-->
					</div>
				</div>
				<!--表格结束 -->
			</div>
		</div>
		
		<script type="text/javascript">
		  function ifdelete(a){
			  
			  var rs = confirm("您确定删除该部门吗？");
			  if(rs==true){
			  $.ajax({  
				    type : 'POST',  
				    url: 'delete.do',
				    contentType: "application/x-www-form-urlencoded",
				    data:{id:a},
				    success : function(dat) {  
				      window.location.href="show.do";	
				    	}    
				});  
		  }
		  return rs;
		  }
		</script>	
		<script>
		 $(function(){
				/* 分页插件使用 */
				$("#page").page({/* #page是分页条div的id，调用分页插件page.js中封装的page函数*/
					pageNo:${department.getPageNo()},/*向page函数传  当前页数，当前页数从controller获取*/
					totalPage:${department.getPages()},/*向page函数传  总页数，总页数从controller获取*/
					url:"${department.getUrl()}"/*向page函数传  处理分页的controller地址*/
				});
			}) 
		</script>
	</body>

</html>